package com._bytecode.__cglib._abstractClassDemo;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibProxy222 implements MethodInterceptor {

    public Object getProxyInstance(){
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(AbstractPurchaser222.class);
        enhancer.setCallback(this);
        return enhancer.create();
    }

    public Object getProjectEnumProxyInstance(){
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(ProjectEnum.class);
        enhancer.setCallback(this);
        return enhancer.create();
    }


    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        System.out.println("before222..");
        Object result = proxy.invokeSuper(obj, args);
        System.out.println("after2222..");
        return result;
    }
}
